/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.unwiredgrain.modeling.sscm.impl;

import com.unwiredgrain.modeling.sscm.Export;
import com.unwiredgrain.modeling.sscm.InnerConnector;
import com.unwiredgrain.modeling.sscm.OuterConnector;
import com.unwiredgrain.modeling.sscm.SSCMPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Export</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.unwiredgrain.modeling.sscm.impl.ExportImpl#getInput <em>Input</em>}</li>
 *   <li>{@link com.unwiredgrain.modeling.sscm.impl.ExportImpl#getOutput <em>Output</em>}</li>
 *   <li>{@link com.unwiredgrain.modeling.sscm.impl.ExportImpl#getInnerIndex <em>Inner Index</em>}</li>
 *   <li>{@link com.unwiredgrain.modeling.sscm.impl.ExportImpl#getOuterIndex <em>Outer Index</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ExportImpl extends BindingImpl implements Export {
	/**
	 * The cached value of the '{@link #getInput() <em>Input</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInput()
	 * @generated
	 * @ordered
	 */
	protected InnerConnector input;

	/**
	 * The cached value of the '{@link #getOutput() <em>Output</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutput()
	 * @generated
	 * @ordered
	 */
	protected OuterConnector output;

	/**
	 * The default value of the '{@link #getInnerIndex() <em>Inner Index</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInnerIndex()
	 * @generated
	 * @ordered
	 */
	protected static final int INNER_INDEX_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getInnerIndex() <em>Inner Index</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInnerIndex()
	 * @generated
	 * @ordered
	 */
	protected int innerIndex = INNER_INDEX_EDEFAULT;

	/**
	 * The default value of the '{@link #getOuterIndex() <em>Outer Index</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOuterIndex()
	 * @generated
	 * @ordered
	 */
	protected static final int OUTER_INDEX_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getOuterIndex() <em>Outer Index</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOuterIndex()
	 * @generated
	 * @ordered
	 */
	protected int outerIndex = OUTER_INDEX_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ExportImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SSCMPackage.Literals.EXPORT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public InnerConnector getInput() {
		if (input != null && input.eIsProxy()) {
			InternalEObject oldInput = (InternalEObject)input;
			input = (InnerConnector)eResolveProxy(oldInput);
			if (input != oldInput) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, SSCMPackage.EXPORT__INPUT, oldInput, input));
			}
		}
		return input;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public InnerConnector basicGetInput() {
		return input;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetInput(InnerConnector newInput, NotificationChain msgs) {
		InnerConnector oldInput = input;
		input = newInput;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SSCMPackage.EXPORT__INPUT, oldInput, newInput);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInput(InnerConnector newInput) {
		if (newInput != input) {
			NotificationChain msgs = null;
			if (input != null)
				msgs = ((InternalEObject)input).eInverseRemove(this, SSCMPackage.INNER_CONNECTOR__EXPORTS, InnerConnector.class, msgs);
			if (newInput != null)
				msgs = ((InternalEObject)newInput).eInverseAdd(this, SSCMPackage.INNER_CONNECTOR__EXPORTS, InnerConnector.class, msgs);
			msgs = basicSetInput(newInput, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SSCMPackage.EXPORT__INPUT, newInput, newInput));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OuterConnector getOutput() {
		if (output != null && output.eIsProxy()) {
			InternalEObject oldOutput = (InternalEObject)output;
			output = (OuterConnector)eResolveProxy(oldOutput);
			if (output != oldOutput) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, SSCMPackage.EXPORT__OUTPUT, oldOutput, output));
			}
		}
		return output;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OuterConnector basicGetOutput() {
		return output;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetOutput(OuterConnector newOutput, NotificationChain msgs) {
		OuterConnector oldOutput = output;
		output = newOutput;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SSCMPackage.EXPORT__OUTPUT, oldOutput, newOutput);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutput(OuterConnector newOutput) {
		if (newOutput != output) {
			NotificationChain msgs = null;
			if (output != null)
				msgs = ((InternalEObject)output).eInverseRemove(this, SSCMPackage.OUTER_CONNECTOR__EXPORTS, OuterConnector.class, msgs);
			if (newOutput != null)
				msgs = ((InternalEObject)newOutput).eInverseAdd(this, SSCMPackage.OUTER_CONNECTOR__EXPORTS, OuterConnector.class, msgs);
			msgs = basicSetOutput(newOutput, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SSCMPackage.EXPORT__OUTPUT, newOutput, newOutput));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getInnerIndex() {
		return innerIndex;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInnerIndex(int newInnerIndex) {
		int oldInnerIndex = innerIndex;
		innerIndex = newInnerIndex;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SSCMPackage.EXPORT__INNER_INDEX, oldInnerIndex, innerIndex));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getOuterIndex() {
		return outerIndex;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOuterIndex(int newOuterIndex) {
		int oldOuterIndex = outerIndex;
		outerIndex = newOuterIndex;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SSCMPackage.EXPORT__OUTER_INDEX, oldOuterIndex, outerIndex));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SSCMPackage.EXPORT__INPUT:
				if (input != null)
					msgs = ((InternalEObject)input).eInverseRemove(this, SSCMPackage.INNER_CONNECTOR__EXPORTS, InnerConnector.class, msgs);
				return basicSetInput((InnerConnector)otherEnd, msgs);
			case SSCMPackage.EXPORT__OUTPUT:
				if (output != null)
					msgs = ((InternalEObject)output).eInverseRemove(this, SSCMPackage.OUTER_CONNECTOR__EXPORTS, OuterConnector.class, msgs);
				return basicSetOutput((OuterConnector)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SSCMPackage.EXPORT__INPUT:
				return basicSetInput(null, msgs);
			case SSCMPackage.EXPORT__OUTPUT:
				return basicSetOutput(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SSCMPackage.EXPORT__INPUT:
				if (resolve) return getInput();
				return basicGetInput();
			case SSCMPackage.EXPORT__OUTPUT:
				if (resolve) return getOutput();
				return basicGetOutput();
			case SSCMPackage.EXPORT__INNER_INDEX:
				return getInnerIndex();
			case SSCMPackage.EXPORT__OUTER_INDEX:
				return getOuterIndex();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SSCMPackage.EXPORT__INPUT:
				setInput((InnerConnector)newValue);
				return;
			case SSCMPackage.EXPORT__OUTPUT:
				setOutput((OuterConnector)newValue);
				return;
			case SSCMPackage.EXPORT__INNER_INDEX:
				setInnerIndex((Integer)newValue);
				return;
			case SSCMPackage.EXPORT__OUTER_INDEX:
				setOuterIndex((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SSCMPackage.EXPORT__INPUT:
				setInput((InnerConnector)null);
				return;
			case SSCMPackage.EXPORT__OUTPUT:
				setOutput((OuterConnector)null);
				return;
			case SSCMPackage.EXPORT__INNER_INDEX:
				setInnerIndex(INNER_INDEX_EDEFAULT);
				return;
			case SSCMPackage.EXPORT__OUTER_INDEX:
				setOuterIndex(OUTER_INDEX_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SSCMPackage.EXPORT__INPUT:
				return input != null;
			case SSCMPackage.EXPORT__OUTPUT:
				return output != null;
			case SSCMPackage.EXPORT__INNER_INDEX:
				return innerIndex != INNER_INDEX_EDEFAULT;
			case SSCMPackage.EXPORT__OUTER_INDEX:
				return outerIndex != OUTER_INDEX_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (innerIndex: ");
		result.append(innerIndex);
		result.append(", outerIndex: ");
		result.append(outerIndex);
		result.append(')');
		return result.toString();
	}

} //ExportImpl
